//
//  ViewController.m
//  CocoaSyncSocket
//
//  Created by 崔逢举 on 20/03/28.
//  Copyright © 2020 崔逢举. All rights reserved.
//

#import "ViewController.h"
#import "SocketManager.h"
#define KScreenWidth     [UIScreen mainScreen].bounds.size.width
@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (weak, nonatomic) IBOutlet UIButton *sendBtn;


@property (weak, nonatomic) IBOutlet UIButton *connectBtn;

@property (weak, nonatomic) IBOutlet UIButton *disConnectBtn;



@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.connectBtn addTarget:self action:@selector(connectAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.disConnectBtn addTarget:self action:@selector(disConnectAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.sendBtn addTarget:self action:@selector(sendAction) forControlEvents:UIControlEventTouchUpInside];
    
    [SocketManager shareInstance].recvImg = self.imageView;
}


//连接
- (void)connectAction {
    BOOL isConnect = [[SocketManager shareInstance] connect];
    if (isConnect ) {
        NSLog(@"开始连接...");
    } else {
        NSLog(@"连接失败");
    }

}
//断开连接
- (void)disConnectAction {
    [[SocketManager shareInstance] disConnect];
}

//发送消息
- (void)sendAction {
    [[SocketManager shareInstance] sendMsg];
}



@end
